package com.itheima.job;

import java.util.ArrayList;
import java.util.Iterator;

public class Test04 {
    public static void main(String[] args) {
        ArrayList<Person> personArr = new ArrayList<>();
        personArr.add(new Person("张三",10,172));
        personArr.add(new Person("李四",12,185));
        personArr.add(new Person("王五",20,180));
        personArr.add(new Person("赵六",22,175));
        personArr.add(new Person("钱七",8,150));

        Iterator<Person> it = personArr.iterator();
//        int max = 0;
        int heiMax = 0;
//        int min = 0 ;
        int heiMin = 999;
        Person maxP = new Person();
        Person minP = new Person();

        while (it.hasNext()){
            Person p = it.next();
            if (p.getHeight()>heiMax){
                heiMax = p.getHeight();
                maxP = p;
            }
            if (p.getHeight()<heiMin){
                heiMin = p.getHeight();
                minP = p;
            }
        }
        //最高的人是张三,身高1.80；最矮的人是李四,身高1.60 。
        System.out.println("最高的人是"+maxP.getName()+",身高"+maxP.getHeight());
        System.out.println("最矮的人是"+minP.getName()+",身高"+minP.getHeight());
    }
}

class Person{
    private String name;
    private Integer age;
    private Integer height;

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", height=" + height +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Integer getHeight() {
        return height;
    }

    public void setHeight(Integer height) {
        this.height = height;
    }

    public Person(String name, Integer age, Integer height) {
        this.name = name;
        this.age = age;
        this.height = height;
    }

    public Person() {
    }
}
